package o;

import android.content.Context;
import android.content.pm.PackageManager.NameNotFoundException;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import com.huawei.gamebox.plugin.gameservice.bean.GameInfo;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;

public final class biu extends eui {
    private static biu ˊ;

    public static class a implements Serializable {
        private String ʼ;
        private String ˊ;
        private String ˋ;
        private String ˎ;
        private String ˏ;
        private String ॱ;
        private boolean ᐝ;

        public a(String str, String str2, String str3, String str4) {
            this.ˎ = str;
            this.ॱ = str2;
            this.ˏ = str3;
            this.ˊ = str4;
            this.ʼ = str;
        }

        public static a ˏ(String str, String str2, String str3, String str4) {
            if (str != null) {
                a aVar = new a(str, str2, str3, str4);
                aVar.ˎ = str;
                aVar.ॱ = str2;
                aVar.ˏ = str3;
                aVar.ˊ = str4;
                aVar.ʼ = str;
                if (str.startsWith("free_form_clone|") || str.startsWith("free_form|")) {
                    aVar.ˋ = str.split("\\|")[1];
                    aVar.ᐝ = str.startsWith("free_form_clone|");
                    return aVar;
                } else if ("all_app".equals(str)) {
                    return aVar;
                }
            }
            Logger.e("BuoyDeviceSession", "newInstance appInfo fail , key is invalid");
            return null;
        }

        public String ˊ() {
            return this.ˎ;
        }

        public String ˎ() {
            return this.ˏ;
        }

        public String ˏ() {
            return this.ˊ;
        }

        public String ॱ() {
            return this.ˋ;
        }

        public String ˋ() {
            return this.ʼ;
        }

        public boolean ʽ() {
            return this.ᐝ;
        }

        public boolean equals(Object obj) {
            if (!(obj instanceof a)) {
                return false;
            }
            return ˋ().equals(((a) obj).ˋ());
        }

        public int hashCode() {
            return ˋ() == null ? "".hashCode() : ˋ().hashCode();
        }

        @NonNull
        public String toString() {
            return ˋ();
        }
    }

    private biu() {
        super("BuoyDeviceSessionV1");
    }

    public static synchronized biu ˋ() {
        biu o_biu;
        synchronized (biu.class) {
            if (ˊ == null) {
                ˊ = new biu();
                ˊ.ˈ();
            }
            o_biu = ˊ;
        }
        return o_biu;
    }

    private void ˈ() {
        if (ॱ("data.version", 0) < 100400000) {
            ArrayList ˊॱ = ˊॱ();
            ArrayList arrayList = new ArrayList();
            Iterator it = ˊॱ.iterator();
            while (it.hasNext()) {
                String str = (String) it.next();
                if (str.startsWith("free_form_clone|") || str.startsWith("free_form|")) {
                    it.remove();
                    arrayList.add(a.ˏ(str, null, null, null));
                }
            }
            ॱ(ˊॱ);
            if (!CollectCheck.isEmpty(arrayList)) {
                arrayList.add(a.ˏ("all_app", null, null, null));
                ˊ(arrayList);
            }
        }
        Context ˎ = fis.ˎ();
        try {
            ˎ("data.version", (long) ˎ.getPackageManager().getPackageInfo(ˎ.getPackageName(), 0).versionCode);
        } catch (NameNotFoundException e) {
            Logger.e("BuoyDeviceSession", e.toString());
        }
    }

    public void ˏ() {
        ˋ("first.switch.game.accelerate.mode", false);
    }

    public boolean ॱ() {
        return ˏ("first.switch.game.accelerate.mode", true);
    }

    public void ˎ() {
        ˋ("first.switch.dnd.mode", false);
    }

    public boolean H_() {
        return ˏ("first.switch.dnd.mode", true);
    }

    public void ʽ() {
        ˋ("first.switch.deep.dnd.mode", false);
    }

    public boolean ʻ() {
        return ˏ("first.switch.deep.dnd.mode", true);
    }

    public void ॱॱ() {
        ˋ("first.switch.key.control.mode", false);
    }

    public boolean ʼ() {
        return ˏ("first.switch.key.control.mode", true);
    }

    public void ᐝ() {
        ˋ("first.switch.calling.dnd.mode", false);
    }

    public boolean ˏॱ() {
        return ˏ("first.switch.calling.dnd.mode", true);
    }

    public void ॱ(ArrayList<String> arrayList) {
        ˋ("permanent.service.list", arrayList);
    }

    public void ˊ(ArrayList<a> arrayList) {
        ˋ("permanent.app.list", arrayList);
    }

    public ArrayList<String> ˊॱ() {
        Serializable ʻ = ʻ("permanent.service.list");
        if (ʻ instanceof ArrayList) {
            return (ArrayList) ʻ;
        }
        return new ArrayList();
    }

    public ArrayList<a> ͺ() {
        Serializable ʻ = ʻ("permanent.app.list");
        if (ʻ instanceof ArrayList) {
            return (ArrayList) ʻ;
        }
        return new ArrayList();
    }

    public ArrayList<String> ˋॱ() {
        Serializable ʻ = ʻ("app.blacklist");
        if (ʻ instanceof ArrayList) {
            return (ArrayList) ʻ;
        }
        return new ArrayList();
    }

    public void ˋ(ArrayList<String> arrayList) {
        ˋ("app.blacklist", arrayList);
    }

    public void ˏ(GameInfo gameInfo, boolean z) {
        if (gameInfo == null || TextUtils.isEmpty(gameInfo.getPackageName())) {
            Logger.e("BuoyDeviceSession", "gameInfo == null || packageName is empty");
        } else {
            ˋ("net.optimization." + gameInfo.getPackageName(), z);
        }
    }

    public boolean ˋ(GameInfo gameInfo) {
        if (gameInfo != null && !TextUtils.isEmpty(gameInfo.getPackageName())) {
            return ˏ("net.optimization." + gameInfo.getPackageName(), false);
        }
        Logger.e("BuoyDeviceSession", "getNetOptimizationStatus fail, gameInfo == null or PackageName is empty)");
        return false;
    }

    public void ˎ(boolean z) {
        ˋ("game.device.status", z);
    }

    public boolean ॱˊ() {
        return ˏ("game.device.status", false);
    }

    public void ˋ(boolean z) {
        ˋ("game.virtual.key.status", z);
    }

    public boolean ᐝॱ() {
        return ˏ("game.virtual.key.status", false);
    }

    public void ॱˋ() {
        ˋ("game.virtual.key.use", true);
    }

    public boolean ॱˎ() {
        return ˏ("game.virtual.key.use", false);
    }

    public boolean ʻॱ() {
        return ˏ("first.switch.keep.luminance.mode", true);
    }

    public void ॱᐝ() {
        ˋ("first.switch.keep.luminance.mode", false);
    }
}
